home *** CD-ROM | disk | FTP | other *** search
/ Aminet 52 / Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso / Aminet / util / moni / Scout-src.lha / netinclude / sys / socket.h < prev    next >
C/C++ Source or Header  |  2002-09-16  |  8KB  |  250 lines

  1. #ifndef SYS_SOCKET_H
  2. #define SYS_SOCKET_H \
  3.        "$Id: socket.h,v 1.1.1.1 2001/11/26 22:21:20 tboeckel Exp $"
  4. /*
  5.  *      Definitions related to sockets: types, address families, options
  6.  *
  7.  *      Copyright © 1994 AmiTCP/IP Group,
  8.  *                       Network Solutions Development, Inc.
  9.  *                       All rights reserved.
  10.  */
  11.  
  12. #ifndef SYS_TYPES_H
  13. #include <sys/types.h>
  14. #endif
  15.  
  16. /*
  17.  * AmiTCP asynchronous event definitions
  18.  */
  19. #define FD_ACCEPT     0x001    /* there is a connection to accept() */
  20. #define FD_CONNECT     0x002    /* connect() completed */
  21. #define FD_OOB         0x004    /* socket has out-of-band data */
  22. #define FD_READ         0x008    /* socket is readable */
  23. #define FD_WRITE     0x010    /* socket is writeable */
  24. #define FD_ERROR     0x020    /* asynchronous error on socket */
  25. #define FD_CLOSE     0x040    /* connection closed (graceful or not) */
  26.  
  27. /*
  28.  * Definition for Release(CopyOf)Socket unique id
  29.  */
  30. #define UNIQUE_ID    (-1)
  31.  
  32. /*
  33.  * Types
  34.  */
  35. #define    SOCK_STREAM    1        /* stream socket */
  36. #define    SOCK_DGRAM    2        /* datagram socket */
  37. #define    SOCK_RAW    3        /* raw-protocol interface */
  38. #define    SOCK_RDM    4        /* reliably-delivered message */
  39. #define    SOCK_SEQPACKET    5        /* sequenced packet stream */
  40.  
  41. /*
  42.  * Option flags per-socket.
  43.  */
  44. #define    SO_DEBUG    0x0001        /* turn on debugging info recording */
  45. #define    SO_ACCEPTCONN    0x0002        /* socket has had listen() */
  46. #define    SO_REUSEADDR    0x0004        /* allow local address reuse */
  47. #define    SO_KEEPALIVE    0x0008        /* keep connections alive */
  48. #define    SO_DONTROUTE    0x0010        /* just use interface addresses */
  49. #define    SO_BROADCAST    0x0020        /* permit sending of broadcast msgs */
  50. #define    SO_USELOOPBACK    0x0040        /* bypass hardware when possible */
  51. #define    SO_LINGER    0x0080        /* linger on close if data present */
  52. #define    SO_OOBINLINE    0x0100        /* leave received OOB data in line */
  53.  
  54. /*
  55.  * Additional options, not kept in so_options.
  56.  */
  57. #define SO_SNDBUF    0x1001        /* send buffer size */
  58. #define SO_RCVBUF    0x1002        /* receive buffer size */
  59. #define SO_SNDLOWAT    0x1003        /* send low-water mark */
  60. #define SO_RCVLOWAT    0x1004        /* receive low-water mark */
  61. #define SO_SNDTIMEO    0x1005        /* send timeout */
  62. #define SO_RCVTIMEO    0x1006        /* receive timeout */
  63. #define    SO_ERROR    0x1007        /* get error status and clear */
  64. #define    SO_TYPE        0x1008        /* get socket type */
  65.  
  66. /*
  67.  * AmiTCP/IP specific socket options
  68.  */
  69. #define SO_EVENTMASK    0x2001        /* socket event mask,     */
  70.                     /* defaults to no events (0) */
  71.  
  72. /*
  73.  * Structure used for manipulating linger option.
  74.  */
  75. struct    linger {
  76.     int    l_onoff;        /* option on/off */
  77.     int    l_linger;        /* linger time */
  78. };
  79.  
  80. /*
  81.  * Level number for (get/set)sockopt() to apply to socket itself.
  82.  */
  83. #define    SOL_SOCKET    0xffff        /* options for socket level */
  84.  
  85. /*
  86.  * Address families.
  87.  */
  88. #define    AF_UNSPEC    0        /* unspecified */
  89. #define    AF_UNIX        1        /* local to host (pipes, portals) */
  90. #define    AF_INET        2        /* internetwork: UDP, TCP, etc. */
  91. #define    AF_IMPLINK    3        /* arpanet imp addresses */
  92. #define    AF_PUP        4        /* pup protocols: e.g. BSP */
  93. #define    AF_CHAOS    5        /* mit CHAOS protocols */
  94. #define    AF_NS        6        /* XEROX NS protocols */
  95. #define    AF_ISO        7        /* ISO protocols */
  96. #define    AF_OSI        AF_ISO
  97. #define    AF_ECMA        8        /* european computer manufacturers */
  98. #define    AF_DATAKIT    9        /* datakit protocols */
  99. #define    AF_CCITT    10        /* CCITT protocols, X.25 etc */
  100. #define    AF_SNA        11        /* IBM SNA */
  101. #define AF_DECnet    12        /* DECnet */
  102. #define AF_DLI        13        /* DEC Direct data link interface */
  103. #define AF_LAT        14        /* LAT */
  104. #define    AF_HYLINK    15        /* NSC Hyperchannel */
  105. #define    AF_APPLETALK    16        /* Apple Talk */
  106. #define    AF_ROUTE    17        /* Internal Routing Protocol */
  107. #define    AF_LINK        18        /* Link layer interface */
  108. #define    pseudo_AF_XTP    19        /* eXpress Transfer Protocol (no AF) */
  109.  
  110. #define    AF_MAX        20
  111.  
  112. /*
  113.  * Structure used by kernel to store most
  114.  * addresses.
  115.  */
  116. struct sockaddr {
  117.     u_char    sa_len;            /* total length */
  118.     u_char    sa_family;        /* address family */
  119.     char    sa_data[14];        /* actually longer; address value */
  120. };
  121.  
  122. /*
  123.  * Structure used by kernel to pass protocol
  124.  * information in raw sockets.
  125.  */
  126. struct sockproto {
  127.     u_short    sp_family;        /* address family */
  128.     u_short    sp_protocol;        /* protocol */
  129. };
  130.  
  131. /*
  132.  * Protocol families, same as address families for now.
  133.  */
  134. #define    PF_UNSPEC    AF_UNSPEC
  135. #define    PF_UNIX        AF_UNIX
  136. #define    PF_INET        AF_INET
  137. #define    PF_IMPLINK    AF_IMPLINK
  138. #define    PF_PUP        AF_PUP
  139. #define    PF_CHAOS    AF_CHAOS
  140. #define    PF_NS        AF_NS
  141. #define    PF_ISO        AF_ISO
  142. #define    PF_OSI        AF_ISO
  143. #define    PF_ECMA        AF_ECMA
  144. #define    PF_DATAKIT    AF_DATAKIT
  145. #define    PF_CCITT    AF_CCITT
  146. #define    PF_SNA        AF_SNA
  147. #define PF_DECnet    AF_DECnet
  148. #define PF_DLI        AF_DLI
  149. #define PF_LAT        AF_LAT
  150. #define    PF_HYLINK    AF_HYLINK
  151. #define    PF_APPLETALK    AF_APPLETALK
  152. #define    PF_ROUTE    AF_ROUTE
  153. #define    PF_LINK        AF_LINK
  154. #define    PF_XTP        pseudo_AF_XTP    /* really just proto family, no AF */
  155.  
  156. #define    PF_MAX        AF_MAX
  157.  
  158. /*
  159.  * Maximum queue length specifiable by listen.
  160.  */
  161. #define    SOMAXCONN    5
  162.  
  163. /*
  164.  * Message header for recvmsg and sendmsg calls.
  165.  * Used value-result for recvmsg, value only for sendmsg.
  166.  */
  167. struct iovec {
  168.     caddr_t    iov_base;
  169.     int    iov_len;
  170. };
  171.  
  172. struct msghdr {
  173.     caddr_t    msg_name;        /* optional address */
  174.     u_int    msg_namelen;        /* size of address */
  175.     struct    iovec *msg_iov;        /* scatter/gather array */
  176.     u_int    msg_iovlen;        /* # elements in msg_iov */
  177.     caddr_t    msg_control;        /* ancillary data, see below */
  178.     u_int    msg_controllen;        /* ancillary data buffer len */
  179.     int    msg_flags;        /* flags on received message */
  180. };
  181.  
  182. #define    MSG_OOB        0x1        /* process out-of-band data */
  183. #define    MSG_PEEK    0x2        /* peek at incoming message */
  184. #define    MSG_DONTROUTE    0x4        /* send without using routing tables */
  185. #define    MSG_EOR        0x8        /* data completes record */
  186. #define    MSG_TRUNC    0x10        /* data discarded before delivery */
  187. #define    MSG_CTRUNC    0x20        /* control data lost before delivery */
  188. #define    MSG_WAITALL    0x40        /* wait for full request or error */
  189.  
  190. /*
  191.  * Header for ancillary data objects in msg_control buffer.
  192.  * Used for additional information with/about a datagram
  193.  * not expressible by flags.  The format is a sequence
  194.  * of message elements headed by cmsghdr structures.
  195.  */
  196. struct cmsghdr {
  197.     u_int    cmsg_len;        /* data byte count, including hdr */
  198.     int    cmsg_level;        /* originating protocol */
  199.     int    cmsg_type;        /* protocol-specific type */
  200. /* followed by    u_char  cmsg_data[]; */
  201. };
  202.  
  203. /* given pointer to struct adatahdr, return pointer to data */
  204. #define    CMSG_DATA(cmsg)        ((u_char *)((cmsg) + 1))
  205.  
  206. /* given pointer to struct adatahdr, return pointer to next adatahdr */
  207. #define    CMSG_NXTHDR(mhdr, cmsg)    \
  208.     (((caddr_t)(cmsg) + (cmsg)->cmsg_len + sizeof(struct cmsghdr) > \
  209.         (mhdr)->msg_control + (mhdr)->msg_controllen) ? \
  210.         (struct cmsghdr *)NULL : \
  211.         (struct cmsghdr *)((caddr_t)(cmsg) + ALIGN((cmsg)->cmsg_len)))
  212.  
  213. #define    CMSG_FIRSTHDR(mhdr)    ((struct cmsghdr *)(mhdr)->msg_control)
  214.  
  215. /* "Socket"-level control message types: */
  216. #define    SCM_RIGHTS    0x01        /* access rights (array of int) */
  217.  
  218. /*
  219.  * 4.3 compat sockaddr, move to compat file later
  220.  */
  221. struct osockaddr {
  222.     u_short    sa_family;        /* address family */
  223.     char    sa_data[14];        /* up to 14 bytes of direct address */
  224. };
  225.  
  226. /*
  227.  * 4.3-compat message header (move to compat file later).
  228.  */
  229. struct omsghdr {
  230.     caddr_t    msg_name;        /* optional address */
  231.     int    msg_namelen;        /* size of address */
  232.     struct    iovec *msg_iov;        /* scatter/gather array */
  233.     int    msg_iovlen;        /* # elements in msg_iov */
  234.     caddr_t    msg_accrights;        /* access rights sent/received */
  235.     int    msg_accrightslen;
  236. };
  237.  
  238. #ifndef KERNEL
  239.  
  240. /*
  241.  * Include socket protos/inlines/pragmas
  242.  */
  243. #if !defined(BSDSOCKET_H) && !defined(CLIB_SOCKET_PROTOS_H)
  244. #include <bsdsocket.h>
  245. #endif
  246.  
  247. #endif /* !KERNEL */
  248.  
  249. #endif /* !SYS_SOCKET_H */
  250.